package blackjack.server;

import java.util.LinkedList;

class OutboundMessages {
	private LinkedList<String> messages = new LinkedList<String>();

	public synchronized void addMessage(String s) { // this lock
		messages.add(s);
		System.out.println(s);
		this.notifyAll(); 
	}

	public synchronized String getMessage() { // this lock
		try {
			while (messages.isEmpty())
				this.wait(); 
		} catch (InterruptedException e) {
		}
		
		String s = messages.getFirst();
		messages.removeFirst();
		return s;
	}
	
}
